<?php
/**
 * Created by PhpStorm.
 * User: G
 * Date: 2021/3/23
 * Time: 下午2:12
 */

namespace app\api\controller;

use app\admin\model\profit\Tour as TourModel;
use app\common\controller\Api;
use think\Exception;

class Tour extends Api
{

    // 无需登录的接口,*表示全部
    protected $noNeedLogin = [''];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    /**
     * 双人游
     * @author G
     * @date 2021-03-23 下午2:19
     */
    public function apply()
    {
        try {

            $shop_id = $this->request->post('shop_id', 0);
            $remarks = $this->request->post('remarks', '');

            $insert_res = TourModel::insert([
                'user_id' => $this->auth->getUser()->id,
                'name' => $this->request->post('name'),
                'mobile' => $this->request->post('mobile'),
                'id_card' => $this->request->post('id_card'),
                'age' => $this->request->post('age'),
                'gender' => $this->request->post('gender'),
                'shop_id' => $shop_id,
                'remarks' => $remarks,
                'createtime' => time(),
                'updatetime' => time()
            ]);

            if(!$insert_res) {
                throw new Exception('保存失败');
            }
        }catch (Exception $e) {
            $this->error($e->getMessage());
        }

        $this->success('成功', []);

    }
}